﻿using Shop.Collect;
using Shop.Model.DB;
using Shop.RemoteModel.LogisticsConfig.Model;
using Shop.Service.Interface;
using WeDonekRpc.Client;
using WeDonekRpc.Model;

namespace Shop.Service.lmpl
{
    internal class LogisticsConfigService : ILogisticsConfigService
    {
        private readonly ILogisticsConfigCollect _Config;

        public LogisticsConfigService (ILogisticsConfigCollect config)
        {
            this._Config = config;
        }

        public long Add (LogisticsConfigAdd add)
        {
            return this._Config.Add(add);
        }

        public LogisticsPrice CalculatePrice (CalculateLogistics param)
        {
            return this._Config.CalculatePrice(param);
        }


        public void Delete (long id)
        {
            DBLogisticsConfig config = this._Config.Get(id);
            this._Config.Delete(config);
        }

        public LogisticsConfigDatum Get (long id)
        {
            return this._Config.Get<LogisticsConfigDatum>(id);
        }
        public LogisticsConfigDatum[] Gets (LQueryParam query)
        {
            return this._Config.Gets<LogisticsConfigDatum>(query);
        }
        public PagingResult<LogisticsConfigDatum> Query (LQueryParam query, IBasicPage paging)
        {
            LogisticsConfigDatum[] list = this._Config.Query<LogisticsConfigDatum>(query, paging, out int count);
            return new PagingResult<LogisticsConfigDatum>(list, count);
        }

        public bool Set (long id, LogisticsConfigSet set)
        {
            DBLogisticsConfig config = this._Config.Get(id);
            return this._Config.Set(config, set);
        }

        public bool SetIsEnable (long id, bool enable)
        {
            DBLogisticsConfig config = this._Config.Get(id);
            return this._Config.SetIsEnable(config, enable);
        }
    }
}
